function djnoctable () {
    $.get("index.php?s=/npfe/noc/shownoc", function(data){
        $("#mainplus").html(data);
        $.parser.parse('#mainplus'); 
    });
}
function djgdtable () {
    $.get("index.php?s=/npfe/gdc/showgd", function(data){
        $("#mainplus").html(data);
        $.parser.parse('#mainplus'); 
    });
}
function djsmjtable () {
    $.get("index.php?s=/npfe/gdc/showsmj", function(data){
        $("#mainplus").html(data);
        $.parser.parse('#mainplus'); 
    });
}
function djhjtable () {
    $.get("index.php?s=/Npfe/Goods/index/mode/exchange", function(data){
        $("#mainplus").html(data);
        $.parser.parse('#mainplus'); 
    });
}
function djtjtable () {
    $.get("index.php?s=/Npfe/Goods/index/mode/return", function(data){
        $("#mainplus").html(data);
        $.parser.parse('#mainplus'); 
    });
}
function viewgdct() {
    var row = $('#gdcltb').datagrid('getSelected');
    if (row) {
        $("#dlg1").dialog({
            title: '查看工单内容',
            width: 800,
            height: 600,
            closed: false,
            cache: false,
            href: 'index.php?s=/Npfe/Gdc/viewgd/cn/'+row.contactnumber+'/time/'+row.time,
            modal: true,
            toolbar: [{
                text:'处理此单',
                iconCls:'icon-undo',
                handler:function(){
                    showgdcl();
                }
                },{
                    text:'重载',
                    iconCls:'icon-reload',
                    handler:function(){
                        viewgdct();
                    }
            }]
        });
    }
}

function viewnocct(){
    var row = $('#noccltb').datagrid('getSelected');
    if (row) {
        $("#dlg1").dialog({
            title: '查看工单内容',
            width: 800,
            height: 600,
            closed: false,
            cache: false,
            href: 'index.php?s=/Npfe/Noc/ViewNocDetails/cn/'+row.cnumber+'/vtime/'+row.time,
            modal: true,
            toolbar:false
        });
    }
}

function showgdcl() {
    var row = $('#gdcltb').datagrid('getSelected');
    if (row) {
        $("#dlg2").dialog({
            title: '处理工单',
            width: 300,
            height: 320,
            closed: false,
            cache: false,
            href: 'index.php?s=/Npfe/Gdc/showinprogress/cn/'+row.contactnumber+'/time/'+row.time,
            modal: false
        });
    }
}
function HjtjView () {
    var row = $("#hjcltb").datagrid('getSelected');
    if (row) {
        $.get('index.php?s=/Npfe/Goods/viewrfs/snid/'+row.snid+'/time/'+row.ctldate,function(data) {
            $("#reviewdlg").dialog({
                title: '单据预览器',
                height: 600,
                width: 800,
                closed: false,
                cache: false,
                toolbar: [{
                    text:'打印',
                    iconCls:'icon-undo',
                    handler:function(){
                        window.open ('index.php?s=/Npfe/Goods/viewrfs/snid/'+row.snid+'/time/'+row.ctldate, 'newwindow', 'height=700, width=1024, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
                    },
                }],
            });
            $("#reviewdlg").html(data);
        });
    };
}
function HjtjPrint () {
    var row = $("#hjcltb").datagrid('getSelected');
    if (row) {
        window.open('index.php?s=/Npfe/Goods/viewrfs/snid/'+row.snid+'/time/'+row.ctldate, 'newwindow', 'height=700, width=1024, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
    };
}
function fsshowgdcl(cn, time) {
    $("#dlg2").dialog({
        title: '处理工单',
        width: 300,
        height: 320,
        closed: false,
        cache: false,
        href: 'index.php?s=/Npfe/Gdc/showinprogress/cn/' + cn + '/time/' + time,
        modal: true
    });
}
function sumbitgdpg(cn,time){
    $("#dlg1").append("<div class=\"sipg\">正在发送...</div>")
    $.post("index.php?s=/Npfe/Gdc/sumbitgdpg/cn/"+cn+"/time/"+time,$("#wgdpg").serialize(),function(data){
        $("#dlg2").html(data)
    })
}
function checknocsubmit(){
    $.post("index.php?s=/npfe/noc/listnoc",$("#gdlb").serialize(),function(data){
    	
        data = eval('('+data+')');//转换成json对象，必须的！！！不然有异常！！！
        $("#noccltb").datagrid('loadData',data);
    })
}
function checkgdsubmit(){
    $.post("index.php?s=/npfe/gdc/listgd/mode/1",$("#gdlb").serialize(),function(data){
        data = JSON.parse(data);//转换成json对象，必须的！！！不然有异常！！！
        $("#gdcltb").datagrid('loadData',data);
    })
}
function checksmjsubmit(){
    $.post("index.php?s=/npfe/gdc/listgd/mode/2",$("#gdlb").serialize(),function(data){
        data = JSON.parse(data);//转换成json对象，必须的！！！不然有异常！！！
        $("#gdcltb").datagrid('loadData',data);
    })
}
function checkhjsubmit(){
    $.post("index.php?s=/Npfe/Goods/listthj/mode/1",$("#gdlb").serialize(),function(data){
        data = JSON.parse(data);//转换成json对象，必须的！！！不然有异常！！！
        $("#hjcltb").datagrid('loadData',data);
    })
}
function checktjsubmit(){
    $.post("index.php?s=/Npfe/Goods/listthj/mode/2",$("#gdlb").serialize(),function(data){
        data = JSON.parse(data);//转换成json对象，必须的！！！不然有异常！！！
        $("#hjcltb").datagrid('loadData',data);
    })
}
function updatehj(cn,time){
    $("#dlg2").dialog({
        title: '处理工单',
        width: 800,
        height: 320,
        closed: false,
        cache: false,
        href: './gongdan/npfe/12.php?action=updatehj&cn=' + cn + '&begintime=' + time,
        modal: true
    });
}
function updatezthhgd(cn,time){
    $(".sipg").append("<div class=\"sipg\">正在发送...</div>")
    $.post("./gongdan/npfe/12.php?action=updatezthhgd&cn="+cn+"&time="+time,$("#zth").serialize(),function(data){
        $(".sipg").html(data)
    })
}
function dvzthhgd(model){
    switch (model){
        case 'gd':
            var row = $('#gdcltb').datagrid('getSelected');
            if (row) {
                $("#dlg2").dialog({
                    title: '处理工单',
                    width: 800,
                    height: 320,
                    closed: false,
                    cache: false,
                    href: './gongdan/npfe/12.php?action=zthh&cn='+row.contactnumber+'&time='+row.time,
                    modal: false
                });
            }
            break;
        case 'noc':
            var row = $('#noccltb').datagrid('getSelected');
            if (row) {
                $("#dlg2").dialog({
                    title: '处理工单',
                    width: 800,
                    height: 320,
                    closed: false,
                    cache: false,
                    href: './gongdan/npfe/12.php?action=zthhnoc&cn='+row.cnumber+'&time='+row.time,
                    modal: false
                });
            }
            break;
    }

}
function submitzthhgd(cn,time){
    $(".sipg").append("<div class=\"sipg\">正在发送...</div>")
    $.post("./gongdan/npfe/12.php?action=submitzthhgd&cn="+cn+"&time="+time,$("#zth").serialize(),function(data){
        $(".sipg").html(data)
    })
}
function resetnoc_add() {
    $("#dlg1").dialog({
        title:'添加工单',
        height: 600,
        width: 400,
        closed: false,
        cache: false,
        href: "index.php?s=/Npfe/Main/nocgdadd"
    });
    $("#dlg1").dialog('open');
}
function resetnoc_edit() {
    var row = $('#noccltb').datagrid('getSelected');
    if (row) {
        $("#dlg1").dialog({
            title: '编辑工单',
            height: 600,
            width: 620,
            closed: false,
            cache: false,
            href: "index.php?s=/Npfe/Main/nocgdedit/snid/" + row.snid + '/time/' + row.time
        });
    }
}
function submitNOCForm() {
    $('#nocaddform').form('submit', {
        url: "index.php?s=/Npfe/Noc/addnoc",
        onSubmit: function() {
            return $(this).form('validate');  
            //进行表单验证
            //如果返回false阻止提交
        },
        success: function(data) {
            $("#dlg1").html(data)
        }
    });
}
function submitNOCEdit(snid, time) {
    var row = $('#noccltb').datagrid('getSelected');
    if (row) {
        $('#nocaddform').form('submit', {
            url: "index.php?s=/Npfe/Noc/editnoc/snid/" + row.snid + "/time/" + row.time,
            onSubmit: function() {
                return $(this).form('validate');
                //进行表单验证
                //如果返回false阻止提交
            },
            success: function(data) {
                $("#dlg1").html(data)
            }
        });
    }
}
function thj_add(mode) {
    $("#dlg1").dialog({
        title:'添加退换机仿真单',
        height: 600,
        width: 800,
        closed: false,
        cache: false,
        toolbar: false,
        href: "index.php?s=/Npfe/Goods/"+mode,
        onClose:function(){
            if(efy != null){
               efy.destroy();
               efy = null; //清除编辑器 
            }
        }
    });
}
function submitHJForm() {
    $('#fzhjform').form('submit', {
        url: "index.php?s=/Npfe/Goods/addthjc/mode/1",
        onSubmit: function() {
            return $(this).form('validate');  
            //进行表单验证
            //如果返回false阻止提交
        },
        success: function(data) {
            $.messager.alert('My Title',data);
            $("#dlg1").dialog('close')
        }
    });
}
function submitTJForm() {
    $('#fztjdform').form('submit', {
        url: "index.php?s=/Npfe/Goods/addthjc/mode/2",
        onSubmit: function() {
            return $(this).form('validate');  
            //进行表单验证
            //如果返回false阻止提交
        },
        success: function(data) {
            $.messager.alert('My Title',data);
            $("#dlg1").dialog('close')
        }
    });
}
function reviewHJForm() {
    $('#fzhjform').form('submit', {
        url: "index.php?s=Npfe/Goods/review/1",
        onSubmit: function() {
            return $(this).form('validate');
            //进行表单验证
            //如果返回false阻止提交
        },
        success: function(data) {
            $("#reviewdlg").dialog({
                title: '预览换机单',
                height: 600,
                width: 800,
                closed: false,
                cache: false,
            });
            $("#reviewdlg").html(data);
        }
    });
}
function reviewTJForm() {
    $('#fztjdform').form('submit', {
        url: "index.php?s=Npfe/Goods/review/2",
        onSubmit: function() {
            return $(this).form('validate');
            //进行表单验证
            //如果返回false阻止提交
        },
        success: function(data) {
            $("#reviewdlg").dialog({
                title: '预览退机单',
                height: 600,
                width: 800,
                closed: false,
                cache: false,
            });
            $("#reviewdlg").html(data);
        }
    });
}